package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.nursing.domain.*;
import com.zzyl.nursing.dto.DeviceFunctionDTO;
import com.zzyl.nursing.dto.ElderlyDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.LoginVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 老人家属Controller
 * 
 * @author ruoyi
 * @date 2025-04-26
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;

    @PostMapping("/login")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto){
        LoginVo vo = familyMemberService.login(dto);
        return success(vo);
    }

    @PostMapping("/add")
    public AjaxResult addElders(@RequestBody ElderlyDto dto){
        familyMemberService.addElders(dto);
        return success();
    }

    @GetMapping("/my")
    public AjaxResult selectList(){
        List<FamilyOlder> list = familyMemberService.selectList();
        return success(list);
    }

    @GetMapping("/list-by-page")
    public AjaxResult list(FamilyOlderParam param){
        List<ElderlyDetail> list = familyMemberService.pageList(param);
        return success(list);
    }

    @GetMapping("/queryServiceProperties/{iotId}")
    public AjaxResult queryServiceProperties(@PathVariable("iotId") String iotId){
        List<DeviceEvent> list = familyMemberService.queryServiceProperties(iotId);
        return success(list);
    }

    @GetMapping("/queryDeviceDataListByDay")
    public AjaxResult queryDeviceDataListByDay(DeviceFunctionDTO dto)
    {
        List<Map<String, Object>> list = familyMemberService.queryDeviceDataListByDay(dto);
        return AjaxResult.success(list);
    }
    @GetMapping("/queryDeviceDataListByWeek")
    public AjaxResult queryDeviceDataListByWeek(DeviceFunctionDTO dto){
        List<Map<String, Object>> list = familyMemberService.queryDeviceDataListByWeek(dto);
        return AjaxResult.success(list);
    }


}
